////////////////////////////////////////////////////////////////////////////////
//
//  FLEX USER GROUP HOKURIKU
//  Copyright 2009 Flex User Group Hokuriku
//  All Rights Reserved.
// 
//  NOTICE: Flex User Group Hokuriku permits you to use, 
//  modify, and distribute this file 
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
package net.fxug.hokuriku.chocolat.service.data
{


    public class SocketData
    {
        public function SocketData()
        {
        }

        public static function getSocketDataForMessage(message:String, vote:String, name:String = ""):XML
        {
            name = SocketData.varidate(name);
            message = SocketData.varidate(message);

            //TODO voteEnabledの解決が必要

            var xml:XML = <message_info>
                    <user_name>{name}</user_name>
                    <message>{message}</message>
                    <vote>{vote}</vote>
                    <voteEnabled>{true}</voteEnabled>
                </message_info>;

            return xml;
        }

        public static function varidate(str:String):String
        {
            str.replace("<", "&gt;");
            str.replace(">", "&lt;");

            return str;
        }
    }
}